//
//  CHTabBarControllerConfig.m
//  crm
//
//  Created by weacar on 2017/12/14.
//  Copyright © 2017年 weacar.com. All rights reserved.
//

#import "CHTabBarControllerConfig.h"
#import "CYLTabBarController.h"
#import "HomeViewController.h"
#import "MessageViewController.h"
#import "AccountViewController.h"

@interface CHTabBarControllerConfig ()

@property (nonatomic, readwrite, strong) CYLTabBarController *tabBarController;

@end

@implementation CHTabBarControllerConfig

- (instancetype)init{
    self = [super init];
    if (self) {
    }
    return self;
}

- (CYLTabBarController *)tabBarController {
    if (!_tabBarController) {
        _tabBarController = [CYLTabBarController tabBarControllerWithViewControllers:self.viewControllers tabBarItemsAttributes:self.tabBarItemsAttributesForController];
        _tabBarController.selectedIndex = 1;
    }
    return _tabBarController;
}


#pragma mark ------------创建底部TabBar主页面------------
- (NSArray *)viewControllers {
    //首页
    HomeViewController *homeVC = [[HomeViewController alloc] init];
    BaseNaviViewController *homeNavigationController = [[BaseNaviViewController alloc]initWithRootViewController:homeVC];
    //消息页面
    MessageViewController *messageVC = [[MessageViewController alloc] init];
    BaseNaviViewController *messageNavigationController = [[BaseNaviViewController alloc]initWithRootViewController:messageVC];
    //个人页面
    AccountViewController *accountVC = [[AccountViewController alloc] init];
    BaseNaviViewController *mineNavigationController = [[BaseNaviViewController alloc]initWithRootViewController:accountVC];
    
    NSArray *viewControllers = @[
                                 messageNavigationController,
                                 homeNavigationController,
                                 mineNavigationController,
                                 ];
    return viewControllers;
}

#pragma mark ----------各个页面属性设置----------
- (NSArray *)tabBarItemsAttributesForController {
    //首页
    NSDictionary *homeTabBarItemsAttributes = @{
                                                CYLTabBarItemImage : @"TabBar_Home",
                                                CYLTabBarItemSelectedImage : @"home_highlight",
                                                };
    //消息
    NSDictionary *messageTabBarItemsAttributes = @{
                                                   CYLTabBarItemTitle : @"消息",
                                                   CYLTabBarItemImage : @"TabBar_Message",
                                                   CYLTabBarItemSelectedImage : @"TabBar_Message",
                                                   };
    //个人
    NSDictionary *mineTabBarItemsAttributes = @{
                                                CYLTabBarItemTitle : @"我的",
                                                CYLTabBarItemImage : @"TabBar_Mine",
                                                CYLTabBarItemSelectedImage : @"TabBar_Mine",
                                                };
    NSArray *tabBarItemsAttributes = @[
                                       messageTabBarItemsAttributes,
                                       homeTabBarItemsAttributes,
                                       mineTabBarItemsAttributes,
                                       ];
    return tabBarItemsAttributes;
}



@end
